//
//  SXTLandingNextViewController.m
//  8.18项目
//
//  Created by ma c on 16/8/18.
//  Copyright © 2016年 zhang. All rights reserved.
//

#import "SXTLandingNextViewController.h"
#import "SXTNextView.h"//下一步view

@interface SXTLandingNextViewController () <UITextFieldDelegate>

@property (nonatomic,strong) SXTNextView * nextView;

@end

@implementation SXTLandingNextViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.edgesForExtendedLayout = 0;
    self.view.backgroundColor = MainColor;
    self.title = @"手机验证码";
    [self addController];
    [self startCreateCodeMethod];

}

//加载控件
- (void)addController{
    [self.view addSubview:self.nextView];
    __weak typeof(self) weakSelf = self;
    [_nextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.left.equalTo(weakSelf.view);
        make.height.equalTo(@140);
    }];
}

//获取验证码网络请求
-(void)startCreateCodeMethod{
    
    [self POSTRequestURL:@"appMenber/createCode.do" param:@{@"MenberId":_userDic[@"userName"]} isSuccess:^(id responseObject){[_nextView GCDTime]; } isError:^(NSError *error){ }];
    
}

- (SXTNextView *)nextView{

    if (!_nextView) {
        _nextView = [[SXTNextView alloc]init];
        _nextView.phoneNumText = _userDic[@"userName"];
        __weak typeof(self) weakSelf = self;
        _nextView.showTimeBlock = ^(){
        
            [weakSelf startCreateCodeMethod];
        };
        _nextView.landingBtnBlock = ^(NSString * codeString){
        
            [weakSelf LandingButtonMethod:codeString];
        };
    }
    return _nextView;
}
- (void)LandingButtonMethod:(NSString *)codeString{

    [self GETRequestURL:@"appMember/appRegistration.do" param:@{@"LoginName":_userDic[@"userName"],@"Lpassword":_userDic[@"password"],@"Code":codeString,@"Telephone":_userDic[@"userName"]} isSuccess:^(id responseObject){NSLog(@"注册:%@",responseObject); } isError:^(NSError *error){NSLog(@"失败:%@",error);}];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
